using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;

namespace Gko.Wpf.Mvvm
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
	public sealed class SubscribeToEventAttribute : Attribute
	{
		private readonly RoutedEvent e;

		public SubscribeToEventAttribute(Type objectType, string eventName)
		{
			this.ObjectType = objectType;
			this.EventName = eventName;
			this.e = (RoutedEvent)objectType.GetField(eventName, BindingFlags.Public | BindingFlags.Static).GetValue(null);
		}

		public Type ObjectType
		{
			get;	
			private set;
		}

		public string EventName
		{
			get;
			private set;
		}

		public RoutedEvent Event
		{
			get
			{
				return this.e;
			}
		}
	}
}